package baseTest;

public class canJump {
    public static void main(String[] args) {
        int[] nums = {2,3,1,1,4};
        System.out.println(process(nums));
    }

    public static boolean process(int[] nums){
        return process(nums,0);
    }

    public static boolean process(int[] nums,int cur){
        if ( cur+nums[cur]>=nums.length || nums[cur] == 0){
            return false;
        } else if (nums[cur] + cur==nums.length-1){
            return true;
        }
        for (int j = 1; j <=nums[cur]; j++) {
            boolean process = process(nums,  cur + j);
            if (process){
                return true;
            }
        }
        return process(nums,cur+nums[cur]);
    }
}
